# src/config/base.py
class BaseConfig:
    ROOT_PATH="/ocrapi"
    SERVER_HOST = "0.0.0.0"
    SERVER_PORT = 8000
    APP_NAME = "身份证OCR识别API"
    APP_DESCRIPTION= "基于EasyOCR的身份证信息提取服务"
    DOCS_URL = "/docs"
    OPENAPI_URL = "/openapi.json"
    REDOC_URL = "/redoc"
    EASYOCR_LANG = "ch_sim"
    EASYOCR_GPU = False
    API_TOKEN = "247c43352945789b2b8dc1336470d815"
    # ip白名单
    IP_WHITELIST = []
    # 基础白名单路径（不含 ROOT_PATH）
    BASE_WHITELIST = [
        "/docs",  # Swagger UI
        "/redoc",  # ReDoc
        "/openapi.json",  # OpenAPI 规范
        "/health",  # 健康检查接口
    ]
    # 动态拼接 ROOT_PATH 生成最终白名单
    @classmethod
    def get_path_whitelist(cls):
        return [f"{cls.ROOT_PATH}{path}" for path in cls.BASE_WHITELIST]

# 使用方式
# path_whitelist = BaseConfig.get_path_whitelist()

class DevConfig(BaseConfig):
    DEBUG = True

class ProdConfig(BaseConfig):
    DEBUG = False
    # 可以覆盖其他配置

# 配置工厂函数
def get_config(env: str = "dev"):
    configs = {
        "dev": DevConfig,
        "prod": ProdConfig,
    }
    return configs.get(env, DevConfig)()